package com.project.gcsj5.service.Impl;

import com.github.pagehelper.PageHelper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.gcsj5.mapper.RecommendMapper;
import com.project.gcsj5.model.Recommend;
import com.project.gcsj5.service.RecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecommendServiceImpl extends ServiceImpl<RecommendMapper, Recommend> implements RecommendService {

    @Autowired
    private RecommendMapper recommendMapper;

    @Override
    public Recommend recommends_by_id(int id) {
        Recommend recommend = recommendMapper.find_by_id_new(id);
        return recommend;
    }

    @Override
    public List<Recommend> recommends_user(int id) {
        List<Recommend> recommends = recommendMapper.find_user_recommends(id);
        return recommends;
    }

    @Override
    public List<Recommend> recommends_list(int pages) {
        PageHelper.startPage(pages,6);
        List<Recommend> recommends = recommendMapper.find_recommends();
        return recommends;
    }

    @Override
    public List<Recommend> recommends_content(String content,int pages) {
        PageHelper.startPage(pages, 6);
        List<Recommend> recommends = recommendMapper.find_by_content(content);
        return recommends;
    }

    @Override
    public Boolean add_view(int id) {
        Boolean a = recommendMapper.add_view(id);
        return a;
    }

    @Override
    public List<Recommend> recommends_hot() {
        List<Recommend> recommends = recommendMapper.find_hot_10();
        return recommends;
    }
}
